/**
 * Created by Janpoem on 2016/1/31 0031.
 */

const db = require('./db');

const Cache = require('./cache');

module.exports = new Cache('serverCache', {
	life: 60 * 30, // 项目缓存30分钟
	onload: function(name, fn) {
		var me = this;
		db.query('select * from server where lan_ip = ? limit 1', [name], function(error, rows) {
			var data = db.row(rows, 0);
			if (data !== false)
				me.save(name, data);
			Cache.call(fn, me, [name, data, true]);
		});
	}
});